﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class SimpleFlyIn : FadeInBase {

    MeshRenderer render;
    Vector3 startPos;
    Vector3 startScale;

    private void Awake()
    {
        startPos = transform.position;
        startScale = transform.localScale;
        transform.position += new Vector3(-4.5f, -3f, 0.1f);
        transform.localScale = Vector3.one * 0.3f;
        render = GetComponentInChildren<MeshRenderer>();
        render.material.color = new Color(1, 1, 1, 0);
    }

    void Start () {
        //pos
        transform.DOMove(startPos, 1.3f);
        //scale
        transform.DOScale(startScale, 1f);

        //alpha fade
        Color temColor = render.material.color;
        Tweener tweener = DOTween.ToAlpha(() => temColor, x => temColor = x, 1f, 1f);
        tweener.OnUpdate(() => { render.material.color = temColor; });
        tweener.OnComplete(() => { });
    }
	
	void Update () {
		
	}
}
